import urllib
import requests
import urllib.request as request
import urllib.error as error

# server 推送
def server_push(SCKEY, msg, title1):
    if SCKEY.isspace() or len(SCKEY)==0:
        return
    else:
        api = 'https://sc.ftqq.com/'+SCKEY+'.send'
        title1 += u"🚀"
        content = msg
        data = {
            "text":title1,
            "desp":content
        }
        try:
            req = requests.post(api, data = data)
            if not req["code"]:
                return {"status": 1, "msg": "Server酱推送服务成功"}
            else:
                return {"status": 0, "errmsg": f"Server酱推送服务失败，{req['message']}"}
        except Exception as e:
            return {"status": 0, "errmsg": f"Server酱推送服务失败，{e}"}


